package com.example.bootdemo.service;

import com.example.bootdemo.gateway.MqttGateway;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
@AllArgsConstructor
public class MqttMessageSender {
    @Autowired
    private MqttGateway mqttGateway;

    /**
     * 发送mqtt消息
     * @param topic 主题
     * @param message 内容
     */
    public void sendMsg(String topic, String message) {
        mqttGateway.sendToMqtt(topic, message);
    }

    /**
     * 发送包含qos的消息
     * @param topic 主题
     * @param qos 质量
     * @param message 消息体
     */
    public void sendMsg(String topic, int qos, String message){
        mqttGateway.sendToMqtt(topic, qos, message);
    }
}